Skip to content

fix(evidence): stop EvidenceAccumulator deadlocking on reentrant append/seal - #46

Merged
imran-siddique merged 2 commits into
agentrust-io:mainfrom
rajnisht7:fix-evidence-accumulator
Sep 5, 2026
Merged

fix(evidence): stop EvidenceAccumulator deadlocking on reentrant append/seal#46
imran-siddique merged 2 commits into
agentrust-io:mainfrom
rajnisht7:fix-evidence-accumulator

Conversation

@rajnisht7

Copy link
Copy Markdown
Contributor

Summary

Python's EvidenceAccumulator used a plain threading.Lock (non-reentrant). If a durable_append callback called back into append(), seal(), or snapshot() on the same thread, it deadlocked forever with no error. The TypeScript SDK already has this exact reentrancy protection (added in #21) Python never got it. This adds the same guard: append/seal now raise EvidenceError on reentrant calls instead of hanging; snapshot stays safely callable reentrantly since it only reads committed state.

Contract impact

  • No wire-contract change
  • Backward-compatible contract change with fixtures
  • Breaking contract change with migration notes

Evidence

  • python tools/sync_schemas.py
  • python tools/check_schemas.py
  • python conformance/runner/validate.py
  • python -m unittest discover -s tests -v
  • python -m build

Privacy and security

  • No real prompts, source, credentials, personal data, or production identifiers added
  • New fields have capture semantics and privacy classification
  • Security-sensitive changes received maintainer review

Limits

This PR fixesthe reentrant calls from the same thread (e.g. a callback calling back into the accumulator). It does not add general thread-safety to other classes like UsageAccumulator, it still has no lock and isnt covered here. It also doesn't address Lock+fork() interaction, which is a pre-existing, unrelated limitation.

Signed-off-by: rajnisht7 <rajnishtiwari9787@gmail.com>

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the accumulator lock and callback handling at this head. All 14 evidence tests pass locally. Independent checks also pass for retrying the same accumulator after rejected callback reentry, 16 concurrent appends with contiguous sequence numbers, and sealing the resulting 17 entries. Restoring the prior implementation makes the reentrant callback hang until the five-second test timeout. CI is green and there are no unresolved review threads.

@imran-siddique imran-siddique left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the accumulator lock and callback handling at this head. All 14 evidence tests pass locally. Independent checks also pass for retrying the same accumulator after rejected callback reentry, 16 concurrent appends with contiguous sequence numbers, and sealing the resulting 17 entries. Restoring the prior implementation makes the reentrant callback hang until the five-second test timeout. CI is green and there are no unresolved review threads.

@imran-siddique
imran-siddique merged commit 885c177 into agentrust-io:main Sep 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants